package com.tjsinfo.tjsoa.workplan.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.vo.User;
import com.tjsinfo.tjsoa.workplan.bo.IWorkPlanDefineBo;

public class AddWorkPlanDefineAction extends Action{

	private IWorkPlanDefineBo workPlanDefineBo;
	
	/**
	 * @return the workPlanDefineBo
	 */
	public IWorkPlanDefineBo getWorkPlanDefineBo() {
		return workPlanDefineBo;
	}

	
	/**
	 * @param workPlanDefineBo the workPlanDefineBo to set
	 */
	public void setWorkPlanDefineBo(IWorkPlanDefineBo workPlanDefineBo) {
		this.workPlanDefineBo = workPlanDefineBo;
	}

	/* (non-Javadoc)
	 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		HttpSession session = request.getSession();
		String[] userarray = request.getParameterValues("checkbox2");
		
		User user = (User)session.getAttribute("user");
		
		if (workPlanDefineBo.addDefine(user, userarray, "D")) {
			//设置成功提示
			request.setAttribute("start", 1);	
			return mapping.findForward("ok");
		} else {
			return mapping.findForward("error");
		}
	
	}
	
}
